/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Estruturas;

import Matriz.ManipulacaoMatriz;
import java.util.LinkedList;

/**
 *
 * @author Linton
 */
public class Mascara5x5 {



    private LinkedList<int[][]> operador1;
    private LinkedList<int[][]> operador2;

    public Mascara5x5()
    {
        operador1 = new LinkedList<int[][]>();
        operador2 = new LinkedList<int[][]>();

        iniciarMascaras();
    }

    private void iniciarMascaras(){

        int[][] mascara1 = {{-1,-1,-1,-1,-1},
                            {-1,0,0,0,-1},
                            {-1,-1,0,-1,-1},
                            {-1,1,1,1,-1},
                            {-1,-1,-1,-1,-1}};

        int[][] mascara2 = {{-1,-1,-1,-1,-1},
                            {-1,-1,0,-1,-1},
                            {-1,1,0,0,-1},
                            {-1,1,1,-1,-1},
                            {-1,-1,-1,-1,-1}};

        girar8x(mascara1, operador1);
        girar8x(mascara2, operador1);

        int[][] mascara3 = {{-1,-1,-1,-1,-1},
                            {-1,1,-1,-1,-1},
                            {-1,1,0,1,-1},
                            {-1,1,1,1,-1},
                            {-1,-1,-1,-1,-1}};

        int[][] mascara4 = {{-1,-1,-1,-1,-1},
                            {-1,-1,-1,1,-1},
                            {-1,1,0,1,-1},
                            {-1,1,1,1,-1},
                            {-1,-1,-1,-1,-1}};

        girar8x(mascara3, operador2);
        girar8x(mascara4, operador2);
    }

    public LinkedList<int[][]> getOperador() {
        return operador1;
    }
    /*
     gira a mascara 45º 7 vezes
     */
    public void girar8x(int[][] mascaraTemp,LinkedList<int[][]> operador ){
        operador.add(mascaraTemp);
        operador.add(girar45graus(mascaraTemp));
        mascaraTemp= girar90graus(mascaraTemp);
        operador.add(mascaraTemp);
        operador.add(girar45graus(mascaraTemp));
        mascaraTemp= girar90graus(mascaraTemp);
        operador.add(mascaraTemp);
        operador.add(girar45graus(mascaraTemp));
        mascaraTemp= girar90graus(mascaraTemp);
        operador.add(mascaraTemp);
        operador.add(girar45graus(mascaraTemp));

    }

    public int[][] girar45graus(int[][] mascara){
        int[][] mascTemp =  ManipulacaoMatriz.preencherMatriz(5, 5, -1);
        for (int x = 1; x < 4; x++) {
            for (int y = 1; y < 4; y++) {
                mascTemp[y+x-2][y-x+2]=mascara[x][y];
            }
        }
        return mascTemp;
    }

    public int[][] girar90graus(int[][] mascara){
        int[][] mascTemp = new int[5][5];
        for (int x = 0; x < 5; x++) {
            for (int y = 0; y < 5; y++) {
               mascTemp[y][4-x]=mascara[x][y];
            }
        }
        return mascTemp;
    }

    public int size(){
        return operador1.size();
    }

    public int[][] getOperador1(int i) {
        return operador1.get(i);
    }

    public int[][] getOperador2(int i) {
        return operador2.get(i);
    }

    public LinkedList<int[][]> getMascaras1() {
        return operador1;
    }

    public LinkedList<int[][]> getMascaras2() {
        return operador2;
    }
}
